import cv2


from utils.detection_optimization import multi_scale_detect, context_assisted_filter,deduplicate_results
from utils.ocr_wrapper import OCRWrapper


def main():
    image_path = r"C:\Users\22840\PycharmProjects\bishes\data\img_8.png"

    # 多尺度检测（内部包含预处理）
    results = multi_scale_detect(image_path, scales=[1.0, 0.5])
    print("多尺度检测返回：", results)

    # 读取原图做辅助过滤
    image = cv2.imread(image_path)
    filtered_results = context_assisted_filter(image, results)
    print("过滤后结果：", filtered_results)

    # 去重
    unique_filtered = deduplicate_results(filtered_results)
    print("去重后结果：", unique_filtered)

    # 这里用元组解包访问
    for text, score in unique_filtered:
        print(f"{text} (置信度: {score:.2f})")


if __name__ == '__main__':
    main()
